package com.gigi.controller;

import com.alibaba.cola.dto.MultiResponse;
import com.alibaba.cola.dto.Response;
import com.gigi.model.*;
import com.gigi.service.manual.JoinCourseManageService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * 入课申请管理
 */
@RestController
@RequestMapping("join-course-manage")
public class JoinCourseManageController {

    private final JoinCourseManageService joinCourseManageService;

    public JoinCourseManageController(JoinCourseManageService joinCourseManageService) {
        this.joinCourseManageService = joinCourseManageService;
    }

    @ApiOperation(value = "新增")
    @PostMapping("/insert")
    public Response insert(@RequestBody @Valid InsertJoinCourseRequest request) {
        return joinCourseManageService.insert(request);
    }

    @ApiOperation(value = "学生入课申请列表")
    @PostMapping("/list-for-student")
    public MultiResponse<JoinCourseDO> listForStudent(@RequestBody @Valid ListExamineRequest request) {
        return joinCourseManageService.listForStudent(request);
    }

    @ApiOperation(value = "老师入课申请列表")
    @PostMapping("/list-for-teacher")
    public MultiResponse<JoinCourseDO> listForTeacher(@RequestBody @Valid ListExamineRequest request) {
        return joinCourseManageService.listForTeacher(request);
    }

    @ApiOperation(value = "审批")
    @PostMapping("/examine")
    public Response examine(@RequestBody @Valid ExamineRequest request) {
        return joinCourseManageService.examine(request);
    }

    @ApiOperation(value = "移除")
    @PostMapping("/move")
    public Response move(@RequestBody @Valid IdRequest request) {
        return joinCourseManageService.move(request);
    }

}
